//Headers
#ifndef ENTITIES_H
#define ENTITIES_H
#include <SDL/SDL.h>
#include <Box2D/Box2D.h>
#include <SDL/SDL_opengl.h>
#include <vector>
using namespace std;

//######## Environ ########
//Rectangle
class EnvRect
{
    private:
        //Type
        int bType;

        //Collision box
        SDL_Rect box;

        //Drawing box
        SDL_Rect d_box;

        //Body
        b2Body* groundBody;
        b2World* pWorld;

        //Gl Texture
        GLuint texture;

        //Times to repeat the texture: x, y
        int re[2];

        //Render?
        bool render;

    public:
        //Initialize
        //Environ();

        //Specify
        void specify(int X, int Y, int W, int H, int T, GLuint eTex, b2World* World);

        //Get box
        SDL_Rect getbox();

        //Render
        void show(SDL_Rect camera);
};

//Triangle
class EnvTri
{
    private:
        //Type
        int bType;

        //Collision box
        SDL_Rect box;

        //Drawing box
        SDL_Rect d_box;

        //Body
        b2Body* groundBody;
        b2World* pWorld;

        //Gl Texture
        GLuint texture;

        //Times to repeat the texture: x, y
        int re[2];

        //Render?
        bool render;

    public:
        //Initialize
        //Environ();

        //Specify
        void specify(int X, int Y, int W, int H, int T, GLuint eTex, b2World* World);

        //Get box
        SDL_Rect getbox();

        //Render
        void show(SDL_Rect camera);
};


//######## Block ########
class Block
{
    private:
        //Draw box
        SDL_Rect d_box, s_box;
        float coords[2];

        //Attributes
        int type, sl, hsl, scale;
        float halfdiag, rot, R, G, B;

        //Physics World
        b2World* pWorld;
        b2Vec2 pPos;

        //Body
        b2Body* pBody;

    public:
        //Initialise
        Block(int X, int Y, int T, b2Vec2 V, b2World* World);

        //Get box
        SDL_Rect getbox();

        //Physics possibly
        void update();

        //Render
        void show(SDL_Rect camera);

        //Destroy
        void destroy();
};


//######## Player ########
class Player
{
    private:
        //Keyboard states
        Uint8 *keystates;

        //Surface box
        SDL_Rect box;

        //Draw box
        SDL_Rect d_box;

        //Attributes
        bool standing, aimdown, shot;
        int dir, P_HA, P_VA;

        //Physics world
        b2World* pWorld;
        b2Vec2 posVec, velVec;
        b2ContactEdge ContEdg;
        b2Contact* Cont;
        bool flag;

        //Body
        b2Body* pBody;

        //Foot
        b2Fixture* foot;

        //Gl Texture
        GLuint pTexture, gTexture;

        //Block Vector
        vector<Block> blocks;
        int nBlocks;

    public:
        //Initialize
        Player(int X, int Y, b2World* World, char* pFilename, char* gFilename);

        //Input
        void handle_input();

        //Motion
        void updatepos();
        void checkStanding(SDL_Rect env[], int N_SOLIDS);

        //Get box
        SDL_Rect getbox();

        //Render
        void show(SDL_Rect camera);
};

#endif
